package controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.DBHelper;
import model.User;

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class ListUsersAction extends Action {
	
	private static Logger logger = Logger.getLogger(ListUsersAction.class);

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		logger.info("Entrando en ListUsersAction");

		List<User> userList = DBHelper.getUserList();

		HttpSession session = request.getSession();

		session.setAttribute("userList", userList);
		
		logger.info("Saliendo de ListUsersAction");

		return mapping.findForward("success");
	}

}
